cmake_minimum_required(VERSION 3.20)


project(echo_server LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

add_compile_options(-g)

# add_compile_definitions(BOOST_ASIO_ENABLE_HANDLER_TRACKING)

find_package(Boost COMPONENTS context system thread REQUIRED) # Asio作为Boost的一部分，通常需要system和thread组件

# 检查是否找到Boost
if(Boost_FOUND)
    message(STATUS "Boost version: ${Boost_VERSION}")
    message(STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost libraries: ${Boost_LIBRARIES}")
    
    # file(GLOB_RECURSE BOOST_SRC "./src/echo_server.cpp")

    add_executable(echo_server ./src/echo_server.cpp)
    add_executable(echo_client_sync ./src/echo_client_sync.cpp)
    add_executable(echo_client_async ./src/echo_client_async.cpp)

    # target_include_directories(echo_server PUBLIC
    #     ./include
    # )


    target_link_libraries(echo_server PUBLIC
        ${Boost_LIBRARIES}
    )
    target_link_libraries(echo_client_sync PUBLIC
        ${Boost_LIBRARIES}
    )
    target_link_libraries(echo_client_async PUBLIC
        ${Boost_LIBRARIES}
    )
else()
    message(FATAL_ERROR "Boost not found")
endif()